{include file="public/headerbase" /}
{include file="public/left" /}
<div class="right-content">
<ul class="we7-page-tab">
	<li class="active">品牌展示</li>
</ul>
<div class="clearfix">
	<form action="" method="get" class="we7-form" role="form">
	<select name="ostarts" id="">
			<option name="ostarts" value="-1">请选择</option>
			<option name="ostarts" value="0">待支付</option>
			<option name="ostarts" value="1">待发货</option>
			<option name="ostarts" value="2">已发货</option>
			<option name="ostarts" value="3">已完成</option>
		</select>
	<div class="input-group pull-left col-sm-4">
		<input type="text" name="omobile" id="omobile" value="" class="form-control" placeholder="搜索联系电话"/>
		<span class="input-group-btn"><button class="btn btn-default" onclick="sear()"><i class="fa fa-search">搜索</i></button></span>
	</div>
	<div class="form-group">
			<!-- <div class="pull-right">
				<a href="{:url('Brand/addlist')}" class="btn btn-primary">添加品牌</a>
			</div> -->
		</div>
	</form>
	<table class="table we7-table table-hover">
		<col width="100px"/>
		<col width="100px"/>
		<col width="100px"/>
		<col width="100px"/>
		<col width="100px"/>
		<col width="150px"/>
		<col width="100px"/>
		<tr>
			<th>排序</th>
			<th>收件人</th>
			<th>联系电话</th>
			<th>收货地址</th>
			<th>订单号</th>
			<th>状态</th>
			<th>操作</th>
		</tr>
		{foreach name="orders" item="val"}
		<tr>
			<th><span>{$val.oid}</span></th>
			<th><span>{$val.ousername}</span></th>
			<th><span>{$val.omobile}</span></th>
			<th><span>{$val.oaddress}</span></th>
			<th><span>{$val.order_sn}</span></th>
			<th><span id="ostarts{$val.oid}">{if condition="$val.ostarts eq 0"}待付款{elseif condition="$val.ostarts eq 1"/}<button onclick="sendOrder({$val.oid})">待发货</button>{elseif condition="$val.ostarts eq 2"/}已发货{else /}已完成{/if}</span></th>
			<th>
				<span class="link-group">
					<a href="{:url('Orders/update')}?oid={$val.oid}">查看</a>
					<a href="javascript:;" class="del" onclick="del(this,{$val.oid})">删除</a>
				</span>
			</th>
		</tr>
		{/foreach}
	</table>
	<div class="pull-right">
		{$page}
	</div>
</div>
			</div>
		</div>
	</div>
</div>
</div>
<script type="text/javascript">
	function sear(){
		var omobile=$('#omobile').val();
			$.ajax({
	        url: "{:url('Orders/index')}",
	        data:{'omobile':omobile},
	        type: "post",
	        dataType: "json",
	        success: function (me) {
	        }
    	});
	}
	function del(obj,oid){
		if(!confirm('确定删除吗')){
			return false;
		}
		$.ajax({
	        url: "{:url('Orders/del')}",
	        data:{'oid':oid},
	        type: "post",
	        dataType: "json",
	        success: function (mega) {
	          if(mega==1){
	           		obj.parentNode.parentNode.parentNode.remove();
	           }else{
	           		util.message('删除失败', '', '');
	           }
	        }
    	});
	}
	function sendOrder(oid)
	{	
		
		var oid=oid;
		if(!confirm('是否改为已发货')){
			return false;
		}
		$.ajax({
			url:"{:url('Orders/sendOrder')}",
			data:{'oid':oid},
			type:"post",
			dataType:"json",
			success:function(msg)
			{
				if(msg==1)
				{
					util.message('发货成功', '', '');
					$("#ostarts"+oid).html("已发货");
				}else{
					util.message('发货异常', '', '');
				}
			}
		})
	}	
</script>
{include file="public/footer" /}